package com.retirement.records.controller;

import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.core.page.TableDataInfo;
import com.retirement.records.dto.OldHealthRecordsPageDto;
import com.retirement.records.vo.OldHealthRecordsPVo;
import com.retirement.records.domain.OldHealthRecords;
import com.retirement.records.service.IOldHealthRecordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijy
 * @since 2023-12-21
 */
@Api(value = "信息管理", tags = "信息管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/records")
public class OldHealthRecordsController extends BaseController {

    private final IOldHealthRecordsService iOldHealthRecordsService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询档案信息")
    public TableDataInfo listOldInformation(OldHealthRecordsPageDto dto){
        startPage();
        return getDataTable(iOldHealthRecordsService.getList(dto));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "查询档案详细信息")
    public OldHealthRecordsPVo getDetail(@PathVariable("id") String id){
        return iOldHealthRecordsService.getDetail(id);
    }

    @PostMapping
    @ApiOperation(value = "新增档案信息")
    public AjaxResult addRecords(@RequestBody OldHealthRecords dto){
        return AjaxResult.success(iOldHealthRecordsService.addRecords(dto));
    }

    @PutMapping()
    @ApiOperation(value = "修改档案信息")
    public AjaxResult updateRecords(@RequestBody OldHealthRecords dto){
        return AjaxResult.success(iOldHealthRecordsService.updateRecords(dto));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除健康档案")
    public AjaxResult deleteRecords(@PathVariable("id") String id){
        return AjaxResult.success(iOldHealthRecordsService.deleteRecords(id));
    }

}
